package com.itboye.boyeshoping.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.boyeshoping.R;
import com.itboye.boyeshoping.fragment.HomeFragment;

/**
 * Created by Administrator on 2018/6/28 0028.
 */

public class HomeGoodsAdapter extends BaseAdapter {
     private Context context;
     private LayoutInflater inflater;
    public HomeGoodsAdapter(Context context){

        this.context=context;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return 4;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyViewHolder holder;
        if (view==null){
            holder=new MyViewHolder();
            view=inflater.inflate(R.layout.item_homegoods,null,false);

            holder.goodTv= (TextView) view.findViewById(R.id.goodTv);
            holder.goodIv= (ImageView) view.findViewById(R.id.goodIv);

            holder.newPrice= (TextView) view.findViewById(R.id.newPrice);
            holder.oldPrice= (TextView) view.findViewById(R.id.oldPrice);
            holder.discountTv= (TextView) view.findViewById(R.id.discountTv);
            view.setTag(holder);
        }else {
            holder= (MyViewHolder) view.getTag();
        }

        //        2、textView设置中划线
//
//        textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线
//        setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
           holder.oldPrice.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线

        return view;
    }

    class MyViewHolder{
        ImageView goodIv;
        TextView goodTv,newPrice,oldPrice,discountTv;

    }
}
